//
//  LGFollowUpRecordCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/7/24.
//

#import "LGFollowUpRecordCell.h"

@interface LGFollowUpRecordCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIButton *numberBtn;
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UIButton *dateBtn;
/**   */
@property (nonatomic , strong)UIView *contentBase;
/**   */
@property (nonatomic , strong)UILabel *contentLabel;

@end

@implementation LGFollowUpRecordCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    [self.numberBtn setTitle:LGNSString(dataDic[@"followup_no"]) forState:UIControlStateNormal];
    self.titleLabel.text = LGNSString(dataDic[@"followup_title"]);
    [self.dateBtn setTitle:LGNSString(dataDic[@"followup_date"]) forState:UIControlStateNormal];
    self.contentLabel.text = LGNSString(dataDic[@"followup_content"]);
    [self.dateBtn setButtonInsetsStyle:LGButtonInsetsStyleRight marginSpace:5];
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.clipsToBounds = YES;
    self.contentView.backgroundColor = [UIColor colorWithString:@"#F9F9F9"];
    [self.contentView addSubview:self.baseView];
    [self.baseView addSubview:self.numberBtn];
    [self.baseView addSubview:self.lineView];
    [self.baseView addSubview:self.titleLabel];
    [self.baseView addSubview:self.dateBtn];
    [self.baseView addSubview:self.contentBase];
    [self.baseView addSubview:self.contentLabel];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
    }];
    [self.numberBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.baseView);
        make.left.equalTo(self.baseView).offset(viewPix(10));
        make.width.height.equalTo(@(viewPix(32)));
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.numberBtn.mas_bottom);
        make.centerX.equalTo(self.numberBtn);
        make.bottom.equalTo(self.baseView);
        make.width.equalTo(@(1));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.numberBtn.mas_right).offset(viewPix(12));
        make.right.equalTo(self.dateBtn.mas_left).offset(-viewPix(12));
        make.centerY.equalTo(self.numberBtn);
    }];
    [self.dateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.baseView).offset(-viewPix(12));
        make.centerY.equalTo(self.numberBtn);
        make.width.equalTo(@(viewPix(100)));
        make.height.equalTo(@(30));
    }];
    [self.contentBase mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.baseView).offset(viewPix(38));
        make.left.equalTo(self.baseView).offset(viewPix(54));
        make.right.equalTo(self.baseView).offset(-viewPix(16));
        make.bottom.equalTo(self.baseView).offset(-viewPix(20));
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.contentBase).offset(viewPix(12));
        make.top.equalTo(self.contentBase).offset(viewPix(10));
        make.right.equalTo(self.contentBase).offset(-viewPix(5));
        make.bottom.equalTo(self.contentBase).offset(-viewPix(10));
    }];
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B3C5D9" offset:CGSizeMake(0, 2) opacity:0.15 radius:0];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(LGDottedLineView *)lineView{
    if(!_lineView){
        _lineView = [[LGDottedLineView alloc]init];
        _lineView.lineColor = @"#A9D2FF";
        _lineView.lineDirection = @"vertical";
    }
    return _lineView;
}

-(UIButton *)numberBtn{
    if(!_numberBtn){
        _numberBtn = [UIButton buttonWithTitle:@"" titleFont:LGFontWeight(18, UIFontWeightSemibold) normalColor:@"#3685EE" selectColor:@"#FFFFFF"];
        [_numberBtn setBackgroundColor:[UIColor colorWithString:@"#F1F5FF"] forState:UIControlStateNormal];
        [_numberBtn setBackgroundColor:[UIColor colorWithString:@"#3685EE"] forState:UIControlStateSelected];
        _numberBtn.userInteractionEnabled = NO;
        _numberBtn.cornerRidus = viewPix(16);
    }
    return _numberBtn;
}

-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(15,UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _titleLabel;
}

-(UIButton *)dateBtn{
    if(!_dateBtn){
        _dateBtn = [UIButton buttonWithTitle:@"" titleFont:LGFont(15) textColor:@"#666666" imageName:@"grayTip12"];
        _dateBtn.userInteractionEnabled = NO;
    }
    return _dateBtn;
}

-(UIView *)contentBase{
    if(!_contentBase){
        _contentBase = [[UIView alloc] init];
        _contentBase.backgroundColor = [UIColor colorWithString:@"#EFEFEF"];
        _contentBase.cornerRidus = 10;
    }
    return _contentBase;
}

-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _contentLabel;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
